Skip to content

rpc: resolve eth_getLogs and trace_filter tags on the committed view - #23279

Merged
AskAlexSharov merged 3 commits into
mainfrom
lupin012/getlogs_tracefilter_overlay_tags
Aug 16, 2026
Merged

rpc: resolve eth_getLogs and trace_filter tags on the committed view#23279
AskAlexSharov merged 3 commits into
mainfrom
lupin012/getlogs_tracefilter_overlay_tags

Conversation

@lupin012

@lupin012 lupin012 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #23194.

Same class of bug as #23193: block tags resolved on the overlay view while the data scan reads the committed view. During an FCU background-commit window, eth_getLogs on latest failed transiently and trace_filter silently omitted the head block.

Changes

  • eth_getLogs: resolve user tags with nil filters, on the same committed view as the latest baseline and the log scan
  • trace_filter: same, plus CheckBlockExecuted on an explicit toBlock so a not-yet-executed block errors instead of being silently clamped away
  • debug_getModifiedAccountsByHash: add the startNum > latestBlock guard
    its ByNumber twin already has

Trade-off (as accepted in #23193): pending resolves to the latest executed block.

Second commit: getLogsV3 complexity

SonarCloud flagged getLogsV3 on this PR (go:S3776, 64 against the 60 allowed). Pure
refactor, no behaviour change: the three duplicated maxResults-capped append loops become
appendErigonLogs, the state-sync lookup becomes borStateSyncLogs. 78 → 44 by gocognit,
Sonar issue now closed as fixed.

Notes

Testing

New tests in overlay_race_test.go, reusing the overlay helper introduced by #23193 plus a new newHeaderAheadTester helper (canonical header committed one past execution progress). All verified red before the fix and green after:

  • TestGetLogs_UsesCommittedFromTag / TestGetLogs_UsesCommittedToTag
  • TestTraceFilter_UsesCommittedFromTag
  • TestTraceFilter_FutureToBlockErrors
  • TestGetModifiedAccountsByHash_FutureStartBlockErrors

The refactor commit is behaviour-preserving, so the existing TestGetLogs_* tests are its
safety net; TestAppendErigonLogs and TestBorStateSyncLogs_NoEvents / _EventsError pin
the extracted helpers

Sonar go:S3776 flagged getLogsV3 at 64, above the 60 limit.

Extract the maxResults-capped log append, which had three near-identical
copies in the loop, into appendErigonLogs, reusing the existing
types.Logs.ToErigonLogs conversion. Extract the bor state sync event
lookup into borStateSyncLogs, mirroring the sibling borReceiptForBlock.
Flatten the bor branch with an early continue and drop the unreachable
header re-fetch: the first Next() of MapTxNum2BlockNumIter always
reports blockNumChanged, so header is non-nil past that block.

In the test package, share the overlay-race chain setup between the two
testers and replace the unused mockBridgeReader with a configurable one.

Cognitive complexity of getLogsV3 goes from 78 to 44 by gocognit.
@lupin012
lupin012 marked this pull request as ready for review August 15, 2026 16:57
@lupin012
lupin012 requested a review from yperbasis as a code owner August 15, 2026 16:57

@AskAlexSharov AskAlexSharov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StateCache doesn't store inverted_index. SharedDomains writing II to ETL. Means RPCD can't read kv.LogAddrIdx - for data which are not in db.

eth_getLogs -> applyFiltersV3 func will not see data which is not in db. I don't know - is it blocker for this pr or not.


Also: solve data integrity bug by adding nil parameter to some func - looks weird. We have tx object which responsibility - to guarantee consistent data view. Other objects around - must not break it. (but it's another story)

@AskAlexSharov
AskAlexSharov added this pull request to the merge queue Aug 16, 2026
Merged via the queue into main with commit d51c654 Aug 16, 2026
134 checks passed
@AskAlexSharov
AskAlexSharov deleted the lupin012/getlogs_tracefilter_overlay_tags branch August 16, 2026 05:19
lupin012 added a commit that referenced this pull request Aug 17, 2026
overlay_race_test.go: keep the branch's overlayAheadHarness and adopt main's
insertOverlayRaceChain helper; the three tests from #23279 now build their API
through the harness.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rpc: eth_getLogs and trace_filter resolve block tags on the overlay view but read data from the committed view

2 participants